﻿
using MainModule.ServiceReference2;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MainModule
{
    public partial class productSet : Form
    {
        ServiceReference2.Container context = new ServiceReference2.Container(new Uri("http://localhost:47318/odata"));
        public productSet()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int No = context.Products.OrderBy(kkk => kkk.ProductNo).ToList().Max(kk=>kk.ProductNo);   
            Product newproduct = new Product { ProductName = this.txt_product_name.Text, ProductNo =No+1, ProductInDate = dateTimePicker1.Value, ProductOutDate = dateTimePicker2.Value };
            context.AddToProducts(newproduct);
            context.SaveChanges();

            MessageBox.Show("품목 : " + txt_product_name.Text + " 가 등록 되었습니다." , "품목 등록 완료 메세지" );
            
        }
        private void productSet_Load(object sender, EventArgs e)
        {
            
        }
    }
}
